package com.example.trans;

import com.example.Employee;
import com.example.PaymentClassification;
import com.example.PayrollDatabase;
import com.example.Transaction;
import com.example.classification.HourlyClassification;
import com.example.classification.TimeCard;
import com.exception.NoSuchEmployeeException;
import com.exception.NotHourlyClassificationException;


public class TimeCardTransaction implements Transaction {

    private  int empId;
    private  String date;
    private  double hours;
    public TimeCardTransaction(int empId, String date, double hours) {
        this.empId = empId;
        this.date = date;
        this.hours = hours;
    }
    public  void execute(){
        Employee e=  PayrollDatabase.getEmployee(empId);
        if(e == null)
            throw new NoSuchEmployeeException();
        PaymentClassification pc = e.getPaymentClassification();
        if(pc instanceof HourlyClassification) {
            HourlyClassification hc = (HourlyClassification) pc;
            TimeCard tc = new TimeCard(date,hours);
            hc.addTimeCard(tc);

        }else{ 
            throw new NotHourlyClassificationException();
        }
       
     
        
    }

}
